import type { FieldNames, TreeActionItem, CheckKeys, ContextMenuItem, ContextMenuOptions, TreeItem } from "./types/tree";
import type { TreeNodeNormal } from "antd/es/tree/Tree";

export interface TreePropsType {
	value?: KeyType[] | CheckKeys;
	renderIcon?: (...params: any[]) => string;
	helpMessage?: string | string[];
	title?: string;
	toolbar?: boolean;
	search?: boolean;
	searchValue?: string;
	checkStrictly?: boolean;
	clickRowToExpand?: boolean;
	checkable?: boolean;
	defaultExpandLevel?: string | number;
	defaultExpandAll?: boolean;
	// 是否显示toolbar的 层级关联/层级独立按钮
	showStrictlyButton?: boolean;
	fieldNames?: FieldNames;
	treeData?: TreeNodeNormal[];
	actionList?: TreeActionItem[];
	expandedKeys?: KeyType[];
	selectedKeys?: KeyType[];
	checkedKeys?: CheckKeys;
	beforeRightClick?: (...arg: any) => ContextMenuItem[] | ContextMenuOptions;
	rightMenuList?: ContextMenuItem[];
	// 自定义数据过滤判断方法(注: 不是整个过滤方法，而是内置过滤的判断方法，用于增强原本仅能通过title进行过滤的方式)
	filterFn?: (searchValue: any, node: TreeItem, fieldNames: FieldNames) => boolean;
	// 高亮搜索值，仅高亮具体匹配值（通过title）值为true时使用默认色值，值为#xxx时使用此值替代且高亮开启
	highlight?: boolean | string;
	// 搜索完成时自动展开结果
	expandOnSearch?: boolean;
	// 搜索完成自动选中所有结果,当且仅当 checkable===true 时生效
	checkOnSearch?: boolean;
	// 搜索完成自动select所有结果
	selectedOnSearch?: boolean;
	loading?: boolean;
	treeWrapperClassName?: string;
}

export const TreePropsDefault = {
	helpMessage: "",
	title: "",
	searchValue: "",
	clickRowToExpand: false,
	defaultExpandLevel: "",
	showStrictlyButton: true,
	actionList: [],
	selectedKeys: [],
	checkedKeys: [],
	beforeRightClick: undefined,
	// 自定义数据过滤判断方法(注: 不是整个过滤方法，而是内置过滤的判断方法，用于增强原本仅能通过title进行过滤的方式)
	filterFn: undefined,
	// 高亮搜索值，仅高亮具体匹配值（通过title）值为true时使用默认色值，值为#xxx时使用此值替代且高亮开启
	highlight: false,
	loading: false
};
